package com.sp.transformation;

import java.io.*;

/**
 * 演示 OutputStreamWriter 使用
 * 把 FileOutputStream 字节流, 转换成字符流 OutputStreamWriter
 * 指定处理的编码gbk/utf-8
 */
public class OutputStreamWriter_ {
    public static void main(String[] args) throws IOException {
        String filePath = "d:\\development\\code\\IO_Test\\news\\story2.txt";
        String charSet = "utf-8";
        OutputStreamWriter outputStreamWriter = new OutputStreamWriter(new FileOutputStream(filePath), charSet);
        outputStreamWriter.write("hi, 牛逼");
        outputStreamWriter.close();
        System.out.println("按照 " + charSet + " 保存文件成功");

    }
}
